<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>预签到</title>
    <script src="/Public/libs/jquery-1.9.1.min.js"></script>
    <script src="/Public/libs/jquery.getParame.js"></script>
    <script src="/Public/libs/store.legacy.min.js"></script>
    <script src="/Public/libs/vconsole.min.js"></script>    
</head>
<body>

</body>
<script>
    $(function () {
        // var vConsole = new VConsole();
        var code = $.getUrlParam('code');
        var state = $.getUrlParam('state');
        // 登录操作
        if (code && state) {
            $.ajax({
                type: 'POST',
                url: '/index.php/Presign/register',
                data: {
                    code: code,
                    state: state
                },
                success: function (data) {
                    if (data['return_code'] == 1) {
                        alert('预签到成功'); 
                        WeixinJSBridge.call('closeWindow');    
                    }else if(data['return_code'] == 2){
                        alert('请先关注公众号');
                        window.location.replace('http://mp.weixin.qq.com/s/bLRXqlqAQ-ptyK8etQ4JGw');
                    }else{
                        alert(data['return_msg']);
                    }
                },
                error: function (err) {
                    alert('服务器出错啦');
                }
            })
        } else {
            alert('参数错误');
        }
    });
</script>

</html>